

public class Clerk{
	private int product=-1;

	public synchronized void setProduct(int product){
		if(this.product!=-1){
			try{
				wait();
			}
			catch(InterruptedException e){
				e.printStackTrace();
			}
		}

		this.product=product;
		System.out.println("ssss product:"+this.product);

		notify();
	}



	public synchronized int getProduct(){
		if(this.product==-1){
			try{
				wait();
			}
			catch(InterruptedException e){
				e.printStackTrace();
			}
		}

		int p=this.product;
		System.out.println("ggggg product"+this.product);
		this.product=-1;


		notify();
		return p;
	}
}


